package helper.base

import java.time.LocalDateTime
import java.time.format.DateTimeFormatter

object TimeHelper {
    fun getTimeString(
        localDateTime: LocalDateTime,
        pattern: String,
    ): String {
        return localDateTime.format(
            DateTimeFormatter.ofPattern(
                pattern,
            )
        )
    }

    fun getNowTimeString(
        timePattern: String,
    ): String {
        return getTimeString(
            LocalDateTime.now(),
            timePattern,
        )
    }

    val aTimePatternString1 = "@yyyy-MMdd-HHmmss"
    val aTimePatternString2 = "@yyyy-MMdd"
    val aTimePatternString3 = "@yyyy-MMdd-HHmm-ss-SSS"
    val aTimePatternString4 = "yyyy_MMdd_HHmm_ss_SSS"

    fun getT2NowTimeString(): String {
        return getNowTimeString(
            aTimePatternString2
        )
    }

    fun getT4NowTimeString(): String {
        return getNowTimeString(
            aTimePatternString4
        )
    }

    fun getT5NowTimeString(): String {
        return "t_${getT4NowTimeString()}"
    }

    var count = 0
    var countMax = 1000
    fun nowCount1000(): String {
        return "${getNowTimeString(aTimePatternString4)}_${String.format("%03d", (count++) % countMax)}"
    }
}